// Algorithm.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

void Phan1_LietKe_PPSinh_DayNhiPhanN()
{
	string path = "Phan1LietKe\\PPSinh\\DayNhiPhan\\";
	string inputpath = path.append("input.txt");
	string outputpath = path.append("output.txt");
	string inputstr,outputstr;
	string line;
	ifstream readfile(inputpath);
	if (readfile.is_open())
	{
		while (getline(readfile,line))
		{
			inputstr = inputstr.append(line).append("\n");
		}
		readfile.close();
	}else{
		cout<<"Unable to open file";
	}

	int k,n;
	const int max = 100;
	int x[max];

	n = stoi(inputstr);

	for (int i = 0; i < max; i++)
	{
		x[i]=0;
	}

	k=n-1;

	while(k>-1){
		for (int i = 0; i < n; i++)
		{
			outputstr.append(to_string(x[i]));	
		}
		outputstr.append("\n");

		k=n-1;
		while(k>-1&&x[k]==1){
			k--;
		}
		if (k>-1)
		{
			x[k]=1;
			for (int i = k+1; i < n; i++)
			{
				x[i]=0;
			}
		}
	}

	ofstream outfile;
	outfile.open(outputpath);
	outfile<<outputstr;
	outfile.close();
	
}

int _tmain(int argc, _TCHAR* argv[])
{
	Phan1_LietKe_PPSinh_DayNhiPhanN();
	return 0;
}

